package com.cmsz.paydemo.function;

import com.cmsz.paydemo.util.FileUtil;
import com.cmsz.paydemo.util.HttpClientUtil;
import com.cmsz.paydemo.util.SignUtil;
import com.cmsz.paydemo.util.XmlUtils;
import com.cmsz.paydemo.util.HttpClientUtil.NotificationProcessor;
/**
 * 
 * TODO 模拟商户发起订单状态查询功能
 * @Date  2017年4月28日 下午4:33:54   	 
 * @author Edison_lv  
 * @version
 */
public class QueryDemo {

	public static void main(String[] args) throws Exception {
		//1:获取查询定单的请求原始报文
		String originData = FileUtil.getData("queryReqData.xml");
		//2:报文签名
		String requestData = SignUtil.sign(originData);
		//3:模拟请求并获取返回报文
		String rspData = HttpClientUtil.sendRequest("query",requestData);
		System.out.println("返回报文 ："+rspData);
		//4:验签报文
		Boolean checkFlag = SignUtil.checkSign(rspData);
		System.out.println("返回报文验签结果："+checkFlag);
		String rtCode = XmlUtils.parseNodeValueFromXml("<RspCode>","</RspCode>", rspData);
		String rtDesc= XmlUtils.parseNodeValueFromXml("<RspDesc>","</RspDesc>", rspData);
		System.out.println("返回报文RspCode:"+rtCode + "     返回报文RspDesc："+rtDesc);
		// print result code
	}
}
